/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tools;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Sik
 */
public class FileBrowser
{

    public static List<String> listDirectory(String path)
    {
        File repertoire = new File(path);
        List<String> files = new ArrayList<String>();
        if (repertoire.isDirectory())
        {
            File[] list = repertoire.listFiles();
            
            if (list == null)
            {
                System.err.println(repertoire + " : Erreur de lecture.");
            } 
            else
            {
                for(File f : list)
                {
                    if(f.isFile())
                    {
                        files.add(f.getAbsolutePath());
                    }
                }
            }
        }
        return files;
    }

    public static List<String> listFiles(String path)
    {
        File repertoire = new File(path);
        List<String> files = new ArrayList<String>();
        if (repertoire.isDirectory())
        {
            File[] list = repertoire.listFiles();

            if (list == null)
            {
                System.err.println(repertoire + " : Erreur de lecture.");
            }
            else
            {
                for(File f : list)
                {
                    files.add(f.getName());
                }
            }
        }
        return files;
    }
}
